var oli1 = document.querySelector('li:first-child');
var oul = document.querySelector('ul');

var timer = null;
function move(aimPosition){
//当前的scrolltop值
var currentScrollTop = document.documentElement.scrollTop;

    var step = (currentScrollTop - aimPosition)/10;
    console.log(step);
    
    
    timer = window.setInterval(function(){
        currentScrollTop -= step;
        document.documentElement.scrollTop -= step;
        if(currentScrollTop == aimPosition){
            window.clearInterval(timer);    
            return;
        }
    },1)


}
oli1.addEventListener('click',function() {
   move(685);
    
})

var oli2 = document.querySelector('li:nth-child(2)');
oli2.addEventListener('click',function() {
    move(975);
})

//右侧栏出现与消失
window.onscroll = function(){
    if(document.documentElement.scrollTop >= 685){
        oul.style.display = 'block';
    }else{
        oul.style.display = 'none';
    }
}
//
var oli3 = document.querySelector('li:nth-child(3)');
oli3.addEventListener('click',function(){
    move(1600);
})
//
var oli4 = document.querySelector('li:nth-child(4)');
oli4.addEventListener('click',function(){
    move(2525);
})

var oli5 = document.querySelector('li:last-child');
oli5.addEventListener('click',function(){
    move(0);
    
})